﻿Imports Crystal.CLL
Imports Infragistics.Win.UltraWinGrid

Public Class frmAdvanceFilter
    Inherits BaseForm

#Region "Fields"
    Public mstrSearchText As String
    Public mstrInitialSearchText As String
    Public mblnFromFilter As Boolean = False
    Public menmAdvancedComparisonOperator As FilterComparisionOperator
#End Region

#Region "On Load"
    Private Sub frmAdvanceFilter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SetOnLoadControls()
    End Sub
#End Region

#Region "Events"

#Region "Text Box Events"

    Private Sub txtSearch_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtSearch.KeyDown
        'Conducts the search on Enter
        If e.KeyCode = Keys.Enter Then
            CallSearch()
        End If
    End Sub

#End Region

#Region "Button Events"

    Private Sub btnFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFilter.Click
        CallSearch()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

#End Region

#End Region

#Region "Procedures"

    Public Sub SetOnLoadControls()
        Me.Text = TitleManager.GetTitle("AdvanceFilter")
        txtSearch.Text = mstrInitialSearchText
        rdContains.Checked = True
    End Sub

    Private Sub CallSearch()
        mblnFromFilter = True
        mstrSearchText = txtSearch.Text.Trim
        If rdContains.Checked Then
            menmAdvancedComparisonOperator = FilterComparisionOperator.Match
        Else
            'menmAdvancedComparisonOperator = FilterComparisionOperator.Match
            menmAdvancedComparisonOperator = FilterComparisionOperator.StartsWith
        End If
        Me.Close()
    End Sub

#End Region

End Class